Repository navigation
Give the combobox, the Treeview cells, and the classic widgets the spacing scale - #1102
Open
beetlebugorg wants to merge 4 commits into
Open
beetlebugorg wants to merge 4 commits into
beetlebugorg wants to merge 4 commits into
Conversation
A theme of Tk puts space in a few places, so a script with little -padx of its own still has room. ztk gave those places about 0, so the Login dialog of tkchat had no margins. The modern theme now fills them from a new spacing scale (--space-1 to --space-5): - the notebook insets its tabs and its client area from its edge, keeps margins around the row of tabs (the part ::tabs), and insets the page inside the client area; - a ttk button, check button, radio button, and menu button keep a margin for the focus ring inside their window; - a ttk label and label frame have padding. ttk::style lookup of -padding, -margin, and -tabmargins gives the value of the theme in the modern look, and configure of those options changes it. The classic theme keeps the values of wish.
The -padding option of a notebook went into its CSS padding too, so it replaced the space of the theme at the edge of the notebook. It is the space around the pages, inside the client area, as in Tk. Two examples of docs/reference/ttk-notebook.tcl depended on the space at the edge: the one of -width compares two widths, and the one of identify uses a point inside the first tab.
The modern theme now gives TCombobox the margin var(--space-1), inside its window, as room for the focus ring. The entry code draws the field, finds the text and the arrow, and places the list in the box inside the margin (entry.frameRect), so a click lands where the field is drawn. The cells and the headings of a Treeview take their padding from the scale: var(--space-2) var(--space-3). `ttk::style lookup` of -padding for the styles Item and Heading, also Treeview.Item and Treeview.Heading, gives the space of the part, and `configure` writes a rule for the part ::item or ::heading. Refs #1091
The modern sheet now takes the padding of button, entry, checkbutton, radiobutton, and labelframe from the spacing scale: Button 4 12 (was 6 12), Entry 4 8 (5 8), Checkbutton and Radiobutton 2 (3 2), and Labelframe 8 12 (10 12). `cget` of -padx and -pady gives the padding of the computed style, and -highlightthickness the width of the focus ring, when the script did not set the option (the style props padx, pady, and focus_ring of options.zig). `identify` of a combobox gives an empty string in its margin. The goldens of the button, the entry, the demo, and the grapheme shot are made again, with the approval of the owner. So are the golden of examples/debug and the numbers of its pages and of tests/debug-examples.sh. Three tests have the new values. Fixes #1091
beetlebugorg
force-pushed
the
theme-paddings
branch
from
December 4, 2026 18:55
b04c845 to
c51bc50
Compare
beetlebugorg
force-pushed
the
ttk-padding
branch
from
December 4, 2026 20:21
5c5d18d to
a955ca2
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1090. The rest of #1070 in the modern look, from the spacing scale of
modern.css(--space-1to--space-5).Summary
Combobox margin.
TCombobox { margin: var(--space-1) }keeps room for the focus ring inside the window, asTButton -margindoes.entry.frameRect). It also finds the text and the arrow there, and places the list there, so a click lands where the field is drawn.identifygives an empty string in the margin.ttk::style lookup TCombobox -margingives2.Treeview cells and headings.
Treeview::itemandTreeview::headinghave the paddingvar(--space-2) var(--space-3). The heading was 5 8 before.ttk::style lookupof-paddingfor the stylesItemandHeading, alsoTreeview.ItemandTreeview.Headingwith classes before them, gives8 4.configureof these styles writes a rule for the part::itemor::heading.Classic widgets.
When the script did not set the option,
cgetof-padx,-pady, and-highlightthicknessgives the padding and the width of the focus ring that the look draws. This applies to button, label, entry, checkbutton, radiobutton, and labelframe. These are the new style propspadx,pady, andfocus_ring.Docs:
docs/styling.md(the table of the space of the theme and a table of the classic widgets) anddocs/differences.md.Fixes #1091
Pictures
The changed goldens are the before and after pictures: see the image diff of
tests/golden/button-*.png,entry-*.png,demo-*.png, andgrapheme-shot-*.png.examples/debug/golden-order.pngis also made again. The numbers ofdocs/debug/visual-diff.md,docs/debug/input.md, andtests/debug-examples.shfollow the new size of the window.Tests
zig build testpasses, with a new test insrc/tests/ttk.zig. It checks:cgetvalues of each classic widget, and a value of the script that wins;lookupofItemandHeading, and the height of a row afterconfigure Item -padding;identifyin the margin and on the arrow.-highlightthicknessis 2, the focus ring. The default stays 1, as in wish.lookup TButton -paddinggives12 4.-margin 0.tests/debug-examples.shpasses.sh tools/ref-check.shhas only the 6 failures of Give the ttk widgets the space of the modern theme #1090, indocs/reference/ttk-notebook.tcl.